<%@ page contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ taglib uri="/struts-dojo-tags" prefix="sx"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Project</title>
<link rel="stylesheet" type="text/css" href="${ pageContext.request.contextPath }/css/common.css">
<link rel="stylesheet" href="${ pageContext.request.contextPath }/css/jquery-ui.css" />
<script type="text/javascript" src="${ pageContext.request.contextPath }/js/jquery-1.6.2.js"></script>
<script type="text/javascript" src="${ pageContext.request.contextPath }/js/jquery-ui-1.8.18.custom.min.js"></script>
	
<script type="text/javascript" >
	$(document).ready(function() {
		
		$("#loadcreateproject").click(function(){
			DIALOG = $("#myDialog");
			DIALOG.dialog({autoOpen: false, 
				                    title: "创建项目",
					                modal: true,
					                width :600,
					                height:320,
	                                close: function() {}
	                                });
			DIALOG.load("${pageContext.request.contextPath}/project/loadCreatePage.action").dialog('open');  
		});
	});
</script>
</head>
<body>
	<div class="header">
		<div class="logo"></div>
	</div>
	<div class="content">
		<div class="projectoverview addProject" >
			<div class="createitem" id="loadcreateproject"></div>
		</div>
		<s:iterator value="projects">
			<div class="projectoverview" id="projectoverview<s:property value='id'/>" >
	
					<div class="top_part">
					    <div id="<s:property value="id"/>" class="logo">
						    <s:if test="%{logo==null}">						     
						      <img src='${ pageContext.request.contextPath }/images/green.jpg'>			
							</s:if>
							<s:else>
							  <img src='${ pageContext.request.contextPath }/<s:property  value="%{logo.path}"/>'  width="70px" height="80px">
							</s:else>
						 </div>
						 <div class="top_part_right">
							 <div class="project_action_btns">
							       <a href="#" title="编辑"><img src="${ pageContext.request.contextPath }/images/icon/pencil_edit.png" id="modifyProject<s:property value='id'/>"/></a>
							        <a href="#" title="设置为默认项目"><img src="${ pageContext.request.contextPath }/images/icon/check-64.png" id="setDefaultProject<s:property value='id'/>"></img></a>
						      </div>
						      <div class="project_name">
							       <a href='${ pageContext.request.contextPath }/project/viewProject.action?projectId=<s:property value="id"/>'>
									   <h4> <s:property value="name" /></h4>
									</a>
						      </div>
						</div>								
					</div>
					
					<div id="projectDescription" class="projectDescription">
					    <p><s:property  value="description"/></p>
					</div>
					<div id="projectTime" class="projectTime">
						<span><s:date name="start_time" format="yyyy-MM-dd"/></span>至<span><s:date name="end_time" format="yyyy-MM-dd"/></span>
					</div>

			</div>
			<script type="text/javascript">
			  $("#<s:property value='id'/>").click(function(){
				  $("#update<s:property value='id'/>").css("display","");
			  });
			  $("#modifyProject<s:property value='id'/>").click(function(){
				DIALOG = $("#myDialog");
				DIALOG.dialog({autoOpen: false, 
						                    title: "修改项目",
							                modal: true,
							                width :500,
							                height:300,
			                                close: function() {}
			                                });
				DIALOG.load("${pageContext.request.contextPath}/project/modifyProject.action?projectId=<s:property value='id'/>").dialog('open');
			   });
				$("#setDefaultProject"+"<s:property value='id'/>").click(
				   function(){
					   $.ajax({
							  "url":"${pageContext.request.contextPath }/user/setDefaultProject.action",
							  "type":"post",
							  "data":{projectId:"<s:property value='id'/>"},
							  "success":function(data,status){
								  if(data){									  
									  $(".projectoverview").removeClass("defaultprojectoverview").addClass("projectoverview");
									  $("#projectoverview"+"<s:property value='id'/>").addClass("defaultprojectoverview");									  								  
								  }
							},
							"error":function(xhr,s1,s2){
								alert('系统出错');
							}
						});
				   }		
				);
				
				$.ajax({
					  "url":"${pageContext.request.contextPath }/user/getDefaultProject.action",
					  "type":"get",
					  "success":function(data,status){
						  if(data){	
							  $("#projectoverview"+data).addClass("defaultprojectoverview");									  								  
						  }
					}
					
				});
				
		
		</script>
		</s:iterator>
		<div class="clear"></div>
		<div id="myDialog" style=" width:300px; height:300px; margin-left:30px;"></div>
		<div id="modifyDialog" style=" width:300px; height:300px; margin-left:30px;"></div>
        </div>
</body>
</html>